#include "gtkprefs.h"

GtkPrefs::GtkPrefs(Glib::RefPtr<Gnome::Glade::Xml> src_ref_xml) {
    ref_xml = src_ref_xml;
    ref_xml->get_widget("PreferencesWindow", PreferencesWindow);
    ref_xml->get_widget("TvPlugins", TvPlugins);
    ref_xml->get_widget("TvSources", TvSources);
    
    
    Glib::RefPtr<Gtk::ListStore> m_refTreeModel = Gtk::ListStore::create(mcp);
    TvPlugins->set_model(m_refTreeModel);
    
    Gtk::TreeModel::Row row = *(m_refTreeModel->append());
    row[mcp.m_col_id]	= 1;
    row[mcp.m_col_type]	= "Billy Bob";
    row[mcp.m_col_url]	= "asdasf";
    
    row = *(m_refTreeModel->append());
    row[mcp.m_col_id]	= 1;
    row[mcp.m_col_type]	= "Bilaaaaa";
    row[mcp.m_col_url]	= "asdasf";
    
    TvPlugins->append_column("ID",		mcp.m_col_id);
    TvPlugins->append_column("Type",	mcp.m_col_type);
    TvPlugins->append_column("URL",		mcp.m_col_type);
    
    
    m_refTreeModel = Gtk::ListStore::create(mcs);
    TvSources->set_model(m_refTreeModel);
    
    TvSources->append_column("Type",	mcs.m_col_type);
    TvSources->append_column("Address",	mcs.m_col_addr);
    TvSources->append_column("Port",	mcs.m_col_port);
    TvSources->append_column("Column",	mcs.m_col_colnum);
    TvSources->append_column("Row",	mcs.m_col_rownum);
    
    Gtk::Button *tmp_bt;
    
    ref_xml->get_widget("ButSrcAdd", tmp_bt);
    if(tmp_bt) {
        tmp_bt->signal_clicked().connect(
                sigc::mem_fun(*this, &GtkPrefs::ButSrcAdd_Clicked) );
    }
    
    ref_xml->get_widget("btnAbout", tmp_bt);
    if(tmp_bt) {
        tmp_bt->signal_clicked().connect(
                sigc::mem_fun(*this, &GtkPrefs::asd) );
    }
}


void GtkPrefs::asd() {
    cout << "about" << endl;
    PreferencesWindow->fullscreen();
}


void GtkPrefs::ButSrcAdd_Clicked() {
    Glib::RefPtr<Gtk::TreeModel> model = TvSources->get_model();
    
    
    /*Gtk::TreeModel::Row row = *(model->append());
     * row[mcs.m_col_type]		= 2;
     * row[mcs.m_col_addr]		= "aksdjkaj";
     * row[mcs.m_col_port]		= 34;
     * row[mcs.m_col_colnum]	= 1;
     * row[mcs.m_col_rownum]	= 2;*/
}
